package com.fishery.quartz.listener;

import com.fishery.quartz.service.QuartzManager;
import com.fishery.quartz.service.TaskService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;


/**
 * 定时器启动类
 */
@Order(value = 1)
@Component
public class StartupQuartz implements CommandLineRunner {

	@Autowired
	private QuartzManager manager;

	@Autowired
	private TaskService sysTaskService;


	@Override
	public void run(String... args) throws Exception {
		System.out.println(">>>>>>>>>>>>>>>启动定时器<<<<<<<<<<<<<");
		System.out.println(">>>>>>>>>>>>>>>执行定时任务<<<<<<<<<<<<<");
		sysTaskService.list(null).forEach(task -> manager.add(task));
	}
}
